package com.member.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.member.common.utils.DateUtils;
import com.member.shop.domain.SysBizMaterialCategory;
import com.member.shop.mapper.SysBizMaterialCategoryMapper;
import com.member.shop.service.ISysBizMaterialCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * 素材分类Service业务层处理
 *
 * @author lixinchen
 * @date 2024-05-08
 */
@Service
public class SysBizMaterialCategoryServiceImpl extends ServiceImpl<SysBizMaterialCategoryMapper, SysBizMaterialCategory> implements ISysBizMaterialCategoryService {
    @Resource
    private SysBizMaterialCategoryMapper sysBizMaterialCategoryMapper;

    /**
     * 查询素材分类
     *
     * @param id 素材分类主键
     * @return 素材分类
     */
    @Override
    public SysBizMaterialCategory selectSysBizMaterialCategoryById(Long id) {
        return sysBizMaterialCategoryMapper.selectById(id);
    }

    /**
     * 查询素材分类列表
     *
     * @param sysBizMaterialCategory 素材分类
     * @return 素材分类
     */
    @Override
    public List<SysBizMaterialCategory> selectSysBizMaterialCategoryList(LambdaQueryWrapper<SysBizMaterialCategory> queryWrapper) {
        return sysBizMaterialCategoryMapper.selectList(queryWrapper);
    }

    /**
     * 新增素材分类
     *
     * @param sysBizMaterialCategory 素材分类
     * @return 结果
     */
    @Override
    public int insertSysBizMaterialCategory(SysBizMaterialCategory sysBizMaterialCategory) {
        sysBizMaterialCategory.setCreateTime(DateUtils.getNowDate());
        return sysBizMaterialCategoryMapper.insert(sysBizMaterialCategory);
    }

    /**
     * 修改素材分类
     *
     * @param sysBizMaterialCategory 素材分类
     * @return 结果
     */
    @Override
    public int updateSysBizMaterialCategory(SysBizMaterialCategory sysBizMaterialCategory) {
        sysBizMaterialCategory.setUpdateTime(DateUtils.getNowDate());
        return sysBizMaterialCategoryMapper.updateById(sysBizMaterialCategory);
    }

    /**
     * 批量删除素材分类
     *
     * @param ids 需要删除的素材分类主键
     * @return 结果
     */
    @Override
    public int deleteSysBizMaterialCategoryByIds(Long[] ids) {
        return sysBizMaterialCategoryMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除素材分类信息
     *
     * @param id 素材分类主键
     * @return 结果
     */
    @Override
    public int deleteSysBizMaterialCategoryById(Long id) {
        return sysBizMaterialCategoryMapper.deleteById(id);
    }
}
